package sample.tree.visitor;

import sample.tree.node.expr.Add;
import sample.tree.node.expr.Sub;
import sample.tree.node.expr.Mul;
import sample.tree.node.expr.Div;
import sample.tree.node.expr.Const;
import sample.tree.node.Node;

public abstract class VoidVisitorAdapter implements VoidVisitor {

	@Override
	public void inAdd(
			final Add node)
	{
		enterAdd(node);

		visit(node.getLhs());
		visit(node.getRhs());

		exitAdd(node);
	}

	@Override
	public void inSub(
			final Sub node)
	{
		enterSub(node);

		visit(node.getLhs());
		visit(node.getRhs());

		exitSub(node);
	}

	@Override
	public void inMul(
			final Mul node)
	{
		enterMul(node);

		visit(node.getLhs());
		visit(node.getRhs());

		exitMul(node);
	}

	@Override
	public void inDiv(
			final Div node)
	{
		enterDiv(node);

		visit(node.getLhs());
		visit(node.getRhs());

		exitDiv(node);
	}

	@Override
	public void inConst(
			final Const node)
	{
		enterConst(node);

		exitConst(node);
	}

	public void enterAdd(
			final Add node)
	{
	}

	public void exitAdd(
			final Add node)
	{
	}

	public void enterSub(
			final Sub node)
	{
	}

	public void exitSub(
			final Sub node)
	{
	}

	public void enterMul(
			final Mul node)
	{
	}

	public void exitMul(
			final Mul node)
	{
	}

	public void enterDiv(
			final Div node)
	{
	}

	public void exitDiv(
			final Div node)
	{
	}

	public void enterConst(
			final Const node)
	{
	}

	public void exitConst(
			final Const node)
	{
	}

	private <T extends Node> void visit(
			final T x)
	{
		if(x != null)
			x.visit(this);
	}
}
